<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org">
<head>
    <th:block th:insert="~{include :: header('课程评论列表')}" />
    <th:block th:insert="~{include :: bootstrap-table-css}" />
</head>
<body class="hold-transition">
<div class="container-fluid mb-2">
    <div class="toolbar" id="toolbar" role="group">
        <form id="formId" class="form-inline">
            <select class="form-control mr-1" name="type">
                <option value="">类型</option>
                <option value="1">资讯</option>
                <option value="2">课程</option>
                <option value="3">直播</option>
                <option value="4">章节</option>
            </select>
            <select class="form-control mr-1" name="status">
                <option value="">状态</option>
                <option value="0">未审核</option>
                <option value="1">已通过</option>
                <option value="-1">未通过</option>
            </select>
            <a class="btn btn-primary btn-rounded mr-1" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
            <a class="btn btn-warning btn-rounded" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
        </form>
    </div>
    <div class="select-table table-striped">
        <table id="bootstrap-table" class="table-striped"></table>
    </div>
</div>
<th:block th:insert="~{include :: footer}" />
<th:block th:insert="~{include :: bootstrap-table-js}" />
<script th:inline="javascript">
    var editFlag = [[${@permission.hasPermi('comment:edit')}]];
    var removeFlag = [[${@permission.hasPermi('comment:remove')}]];
    var prefix = "/comment";
    $(function() {
        var options = {
            showSearch: false,
            showRefresh: false,
            showToggle: false,
            showColumns: false,
            url: prefix + "/list.json",
            removeUrl: prefix + "/remove.json",
            modalName: "课程评论",
            columns: [
                {
                    field: 'commentId',
                    title: 'Id'
                },
                {
                    field: 'userName',
                    title: '昵称',
                    formatter: function(value, row, index) {
                        return value+"("+row.userId+")";
                    }
                },
                {
                    field: 'mobile',
                    title: '手机'
                },
                {
                    field: 'content',
                    title: '评论内容',
                    width:300
                },
                {
                    field: 'status',
                    title: '状态', formatter: function(value, row, index) {
                        switch (value) {
                            case -1:
                            return "<span class='badge badge-warning'>未通过</span>"
                            case 0:
                                return "<span class='badge badge-danger'>未审核</span>"
                            case 1:
                                return "<span class='badge badge-primary'>已通过</span>"
                            default:
                                return "-"
                        }
                    }
                },
                {
                    field: 'addTime',
                    title: '时间',
                    width:200
                },
                {
                    title: '操作',
                    align: 'center',
                    formatter: function(value, row, index) {
                        var actions = [];
                        if(row.status == 0){
                            actions.push('<a class="btn btn-success btn-xs" href="javascript:void(0)" onclick="commenteStatus(\'' + row.commentId + '\',1)"><i class="fa fa-check"></i>通过</a> ');
                            actions.push('<a class="btn btn-primary btn-xs" href="javascript:void(0)" onclick="commenteStatus(\'' + row.commentId + '\',-1)"><i class="fa fa-reply-all"></i>驳回</a> ');
                        }
                        actions.push('<a class="btn btn-info btn-xs" href="javascript:void(0)" onclick="commentInfo(\'' + row.commentId + '\')"><i class="fa fa-search"></i>详情</a> ');
                        actions.push('<a class="btn btn-danger btn-xs" href="javascript:void(0)" onclick="$.operate.remove(\'' + row.commentId + '\')"><i class="fa fa-remove"></i>删除</a>');
                        return actions.join('');
                    }
                }]
        };
        $.table.init(options);
    });

    //审核
    function commenteStatus(commentId,status) {
        table.set();
        if (status === 1) {
            str = "确定审核通过操作吗"
        } else {
            str = "确定审核驳回操作吗"
        }
        $.modal.confirm(str, function () {
            var data = {"commentId":commentId,"status":status};
            $.operate.submit("/comment/status.json", "post", "json", data);
        });
    }

    //评论详情
    function commentInfo(id) {
        layer.open({
            type: 2,
            maxmin: false,
            shade: 0.3,
            title: "评论详细",
            fix: false,
            area: ['65%', '90%'],
            content: "/comment/view.html?id="+id
        });
    }
</script>
</body>
</html>